Tweak reader boundary.
authoroliskoli <oliskoli>
Thu, 16 Nov 2006 21:20:28 +0000 (21:20 +0000)
committeroliskoli <oliskoli>
Thu, 16 Nov 2006 21:20:28 +0000 (21:20 +0000)
hsa_ndv.c

index bb85c71c738a56822c7e6c63071c024158359b56..fba334f0f5156fb541e78cd31abc346e3bf0e389 100644 (file)
--- a/hsa_ndv.c
+++ b/hsa_ndv.c
@@ -226,14 +226,13 @@ static void
 hsa_ndv_read(void)
 {
        int len;
-       char buf[MY_CBUF];
-       memset(buf, 0, MY_CBUF);
+       char buf[MY_CBUF + 1];
        
-       while ((len = fread(buf, 1, sizeof(buf), fd))) 
+       while ((len = fread(buf, 1, sizeof(buf) - 1, fd))) 
        {
                char *bad;
 
-               buf[len-1] = 0;
+               buf[len] = '\0';
                if (NULL != strstr(buf, "nver=1"))
                {//its the older format, not xml
                        fseek(fd, 0, SEEK_SET);
@@ -241,7 +240,8 @@ hsa_ndv_read(void)
                        break;
                }
                //grumble - have to remove \x1f's from sirius attributes
-               while (NULL != (bad = strchr(buf, '\x1f')))
+               bad = buf;
+               while (NULL != (bad = strchr(bad, '\x1f')))
                {
                        *bad = REPLACEMENT_SIRIUS_ATTR_SEPARATOR;
                }